/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  8
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       volVectorField;
    location    "0";
    object      U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 1 -1 0 0 0 0];

internalField   uniform (0 0 0);

boundaryField
{
    frontAndBack
    {
        type            empty;
    }
    mainCylinder
    {
        type            noSlip;
    }
    topControlCylinder
    {
      type            codedFixedValue;
        value           uniform (0 0 0);
        name            topControlCyl;

        code
        #{

            const int startTime = 8;
            const int rampTime = 5;
            const scalar time = this->db().time().value();
            const fvPatch& boundaryPatch = patch();

            const vectorField& Cf = boundaryPatch.Cf();

            vectorField rot(Cf.size(), vector(0.3,0.52,0));

            const scalar f = -20;

            if (time > (startTime+rampTime))
            {
                rot = f*vector(0,0,1) ^ Cf;
            }
            else if(time > startTime){
                rot = f * ((time - startTime) / rampTime) *vector(0,0,1) ^ Cf;
            }


            operator==(rot);

        #};
  }
    bottomControlCylinder
    {
      type            codedFixedValue;
        value           uniform (0 0 0);
        name            bottomControlCyl;

        code
        #{

            const int startTime = 8;
            const int rampTime = 5;
            const scalar time = this->db().time().value();
            const fvPatch& boundaryPatch = patch();

            const vectorField& Cf = boundaryPatch.Cf();

            vectorField rot(Cf.size(), vector(0.3,-0.52,0));

            const scalar f = 20;

            if (time > (startTime+rampTime))
            {
                rot = f*vector(0,0,1) ^ Cf;
            }
            else if(time > startTime){
                rot = f * ((time - startTime) / rampTime) *vector(0,0,1) ^ Cf;
            }

            operator==(rot);

        #};
  }

    inlet
    {
      type            codedFixedValue;
        value           uniform (0 0 0);
        name            inletControl;

        code
        #{
          const scalar t = this->db().time().value();
          const scalar t0 = 1;
          const vector x0(10, 0, 0);
          if(t> t0){
            operator==( x0 );
          }
          else{
            operator==( x0 * (t / t0));
          }

        #};

    }
    outlet
    {
        type            zeroGradient;
    }
    topAndBottom
    {
        type            slip;
    }
    defaultFaces
    {
      type              slip;
    }
}


// ************************************************************************* //
